package com.haixiaoke.saas.enterprise.setSwitch.controller;

import java.util.List;

import com.haixiaoke.saas.common.annotation.Log;
import com.haixiaoke.saas.common.annotation.TenantScope;
import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.core.page.TableDataInfo;
import com.haixiaoke.saas.common.enums.BusinessType;
import com.haixiaoke.saas.common.tenant.TenantContext;
import com.haixiaoke.saas.setSwitch.domain.SetSwitch;
import com.haixiaoke.saas.setSwitch.service.ISetSwitchService;
import com.haixiaoke.saas.system.BaseController;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 订单审核状态Controller
 *
 * @author qixi
 * @date 2024-03-28
 */
@RestController
@RequestMapping("/enterprise/setSwitch/setSwitch")
public class EnterpriseSetSwitchController extends BaseController {
    @Autowired
    private ISetSwitchService setSwitchService;

    /**
     * 查询订单审核状态列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:setSwitch:list')")
    @GetMapping("/list")
    public TableDataInfo list(SetSwitch setSwitch) {
        startPage();
        List<SetSwitch> list = setSwitchService.selectSetSwitchList(setSwitch);
        return getDataTable(list);
    }

    /**
     * 获取订单审核状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:setSwitch:getInfoByTenantId')")
    @GetMapping()
    @TenantScope
    public AjaxResult getInfoByTenantId() {
        String tenantId = TenantContext.getTenantId();
        return success(setSwitchService.selectSetSwitchByTenantId(tenantId));
    }

    /**
     * 获取订单审核状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:setSwitch:query')")
    @GetMapping(value = "/{setSwitchId}")
    public AjaxResult getInfo(@PathVariable("setSwitchId") Long setSwitchId) {
        return success(setSwitchService.selectSetSwitchBySetSwitchId(setSwitchId));
    }

    /**
     * 新增订单审核
     */
    @PreAuthorize("@ss.hasPermi('enterprise:setSwitch:add')")
    @Log(title = "订单审核状态", businessType = BusinessType.INSERT)
    @PostMapping
    @TenantScope
    public AjaxResult add(@RequestBody SetSwitch setSwitch) {
        return toAjax(setSwitchService.insertSetSwitch(setSwitch));
    }

    /**
     * 修改订单审核状态
     */
    @PreAuthorize("@ss.hasPermi('enterprise:setSwitch:edit')")
    @Log(title = "订单审核状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SetSwitch setSwitch) {
        return toAjax(setSwitchService.updateSetSwitch(setSwitch));
    }

    /**
     * 删除订单审核状态
     */
    @PreAuthorize("@ss.hasPermi('enterprise:setSwitch:remove')")
    @Log(title = "订单审核状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{setSwitchIds}")
    public AjaxResult remove(@PathVariable Long[] setSwitchIds) {
        return toAjax(setSwitchService.deleteSetSwitchBySetSwitchIds(setSwitchIds));
    }
}
